﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spinning.Spinning.Unitity;
using Microsoft.Xna.Framework;
using Spinning.Spinning.EntityModifiers;
using Spinning.Spinning.Level;
using Microsoft.Xna.Framework.Input.Touch;

namespace Spinning.Spinning.Entity
{
    class StartScene : BaseScene
    {
        public StartScene() : base()
        {
            Size = new Vector2(1);
        }

        public override void OnLoad()
        {
            base.OnLoad();
            Sprite backGroundSprite = new Sprite();
            backGroundSprite.textureName = "p1/page01";
            backGroundSprite.ZIndex = Constants.background;
            backGroundSprite.OnLoad();
            this.Attach(backGroundSprite);

            ButtonSprite practiceSprite = new ButtonSprite();
            practiceSprite.textureName = "p1/practice";
            practiceSprite.ZIndex = Constants.ui;
            practiceSprite.Position = new Vector2(15, 670);
            practiceSprite.OnLoad();
            TouchManager.RegisteTouchArea(practiceSprite);
            this.Attach(practiceSprite);

            ButtonSprite playSprite = new ButtonSprite();
            playSprite.textureName = "p1/play";
            playSprite.ZIndex = Constants.ui;
            playSprite.Position = new Vector2(270, 680);
            playSprite.OnLoad();
            TouchManager.RegisteTouchArea(playSprite);
            this.Attach(playSprite);

            playSprite.OnTouchEvent += OnPlayTouch;
            practiceSprite.OnTouchEvent += OnPracticeTouch;
        }

        void OnPlayTouch(BaseEntity entity, TouchLocation touchLocation) 
        {
            Game1.stageManager.GoToScene("role");
        }

        void OnPracticeTouch(BaseEntity entity, TouchLocation touchLocation)
        {
            Game1.stageManager.GoToScene("menu");
        }

        void on_playSpriteTouchEvent_Touched(BaseEntity entity, TouchLocation touchLocation)
        {
            entity.AddModifier(new ScaleModifier(0,2,new Vector2(1,1),new Vector2(0,0)));
        }


        public override BaseScene Clone()
        {
            BaseScene scene = new StartScene();
            scene.Size = new Vector2(Constants.Window_Width, Constants.Window_Height);
            scene.OnLoad();
            scene.SortChildren();
            return scene;
        }
    }
}
